//
//  EmotionCollectionViewCell.swift
//  emojiKeyboardDemo
//
//  Created by Jin on 2018/5/17.
//  Copyright © 2018年 Jin. All rights reserved.
//

import UIKit

class EmotionCollectionViewCell: UICollectionViewCell {
    
    //懒加载
    private lazy var emotionBtn:UIButton = UIButton()
    
    //属性
    var emotion : Emotion?{
        didSet{
            guard let emotion = emotion else {
                return
            }
            emotionBtn.setImage(UIImage(contentsOfFile: emotion.pngPath ?? ""), for: .normal)
            emotionBtn.setTitle(emotion.emojiCode, for: .normal)
            
            if emotion.isRemove {
                emotionBtn.setImage(UIImage(named: "compose_emotion_delete"), for: .normal)
            }
        }
    }
    
    
    //初始化
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension EmotionCollectionViewCell {
    private func setupUI(){
        contentView.addSubview(emotionBtn)
        emotionBtn.frame = contentView.bounds
        emotionBtn.isUserInteractionEnabled = false
        emotionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
    }
}
